package com.im.project.controller;

import com.im.common.result.JsonResult;
import com.im.project.entity.dto.DeleteChatDto;
import com.im.project.service.ChatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 会话 控制层
 *
 * @author yunZhouJiaDi
 */
@RestController
@RequestMapping("/chat")
@Api(tags = "ChatController", description = "会话相关接口")
public class ChatController {

    @Resource
    private ChatService chatService;

    @DeleteMapping("/delete")
    @ApiOperation("删除会话")
    public JsonResult deleteChat(@Validated @RequestBody DeleteChatDto deleteChatDto) {
        return JsonResult.success(chatService.deleteChat(deleteChatDto));
    }

    @DeleteMapping("/clear")
    @ApiOperation("清空会话")
    public JsonResult clearChat(@Validated @RequestBody DeleteChatDto deleteChatDto) {
        return JsonResult.success(chatService.clearChat(deleteChatDto));
    }

}
